<template>
  <div class="width-style">
    <LevelOnePageTop moduleName="常见慢性病分类" :catagoryList="catagoryList"/>
    <el-row :gutter="20">
      <el-col :span="18">
        <div class="grid-content">
          <InnerModuleLong innerModuleName="慢性呼吸道疾病" :list="respiratoryList"  :picSrc="require('@/assets/images/chronicRespiratoryDisease_2.jpg')" routeName="/chronicdisease/chronicrespiratorydisease"/>
        </div>
      </el-col>
      <el-col :span="6">
        <div class="grid-content">
          <ModuleAdviser :doctorList="doctorList"/>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import ModuleAdviser from "@/components/moduleAdviser.vue";
import InnerModule from "@/components/innerModule.vue";
import {renderTime} from '@/utils/tools.js'

export default {
  layout: "homeLayout",
  components: { ModuleAdviser, InnerModule},
  // props:['moduleName'],
  async asyncData({app}) {
    //获取当前类下的最热文章
    let res = await app.api.reqGeneralAllByCatalogue(10);
    if (res.code === 200) {
      for (let item of res.rows) {
        item.publishTime = renderTime(item.publishTime);
      }
    }
    //获取医生等列表
    let doctorRes=await app.api.reqAllDoctor();
    if(doctorRes.code===200){
      for(let doctor of doctorRes.rows){
        doctor.doctorAvatar=app.api.BASEURL+doctor.doctorAvatar
      }
    }
    //获取当类下的子分类的文章
    //呼吸道疾病
    let respiratoryRes1 = await app.api.reqCoreGeneralByPage(114,1,3);
    let respiratoryRes2 = await app.api.reqCoreGeneralByPage(115,1,3);
    let respiratoryList
    if (respiratoryRes1.code === 200&&respiratoryRes2.code===200) {
      respiratoryList=respiratoryRes1.rows.concat(respiratoryRes2.rows)
      for (let item of respiratoryList) {
        item.publishTime = renderTime(item.publishTime);
      }
    }
    //
    // let respiratoryRes = await app.api.reqGeneralAllByCatalogue(30);//慢性呼吸道疾病
    // if (respiratoryRes.code === 200) {
    //   for (let item of respiratoryRes.rows) {
    //     item.publishTime = renderTime(item.publishTime);
    //   }
    // }

    return {
      catagoryList:res.rows,
      doctorList:doctorRes.rows,
      // respiratoryList: respiratoryRes.rows,
      respiratoryList,
    }
  },
};
</script>

<style scoped lang="less">
.el-row {
  margin-bottom: 20px;
  &:last-child {
    margin-bottom: 0;
  }
}
.grid-content {
  min-height: 36px;
}
.row-bg {
  padding: 10px 0;
  background-color: #f9fafc;
}
.module-name {
  font-size: 20px;
  .icon-traditional {
    font-size: 24px;
    color: @themeColor;
  }
}
.new-champions-control-img {
  width: 120px;
  height: 120px;
  margin-left: 20px;
  margin-bottom: 10px;
  margin-right: 20px;
}
.ncc-title{
  margin-bottom: 70px;
}
.ncc-link{
  font-size: 19px;
  margin-top: 20px;
  margin-bottom: 10px;

}
</style>
